#ifndef P2P_BASE_BASICPACKETSOCKETFACTORY_H_
#define P2P_BASE_BASICPACKETSOCKETFACTORY_H_

#include "packetsocketfactory.h"

namespace base
{
	class AsyncSocket;
	class SocketFactory;
	class Thread;

	class BasicPacketSocketFactory : public PacketSocketFactory
	{
	public:
		BasicPacketSocketFactory();
		explicit BasicPacketSocketFactory(Thread* thread);
		explicit BasicPacketSocketFactory(SocketFactory* socket_factory);
		virtual ~BasicPacketSocketFactory();

		virtual AsyncPacketSocket* CreateUdpSocket(
			const SocketAddress& address, int min_port, int max_port);
		virtual AsyncPacketSocket* CreateServerTcpSocket(
			const SocketAddress& local_address, int min_port, int max_port, int opts);
		virtual AsyncPacketSocket* CreateClientTcpSocket(
			const SocketAddress& local_address, const SocketAddress& remote_address,
			const ProxyInfo& proxy_info, const std::string& user_agent, int opts);

	private:
		int BindSocket(AsyncSocket* socket, const SocketAddress& local_address,
			int min_port, int max_port);

		SocketFactory* socket_factory();

		Thread* thread_;
		SocketFactory* socket_factory_;
	};

}	// namespace base

#endif	// P2P_BASE_BASICPACKETSOCKETFACTORY_H_